package org.testfire.realm.util;

/**
 * Created by IntelliJ IDEA.
 * User: Granum
 * Date: Jan 14, 2007
 * Time: 1:03:37 PM
 */
public class ReflectionTools {

	/**
	 * Converts a property string to it's corresponding getter method name.
	 * For example: toGetter("someProperty") returns "getSomeProperty";
	 *
	 * @param property The property for which a getter is desired.
	 * @return The getter corresponding to a property name.
	 */
	public static String toGetter(String property) {
		return "get" + capFirstChar(property);
	}


	/**
	 * Converts a property string to it's corresponding setter method name.
	 * <p/>
	 * For example: toSetter("someProperty") returns "setSomeProperty";
	 *
	 * @param property The property for which a setter is desired.
	 * @return The setter corresponding to a property name.
	 */
	public static String toSetter(String property) {
		return "set" + capFirstChar(property);
	}

	/**
	 * Capitalize the first character in the passed String.
	 * <p/>
	 * For example: capFirstChar("someProperty") returns "SomeProperty".
	 *
	 * @param str The String to modify.
	 * @return String, with the first letter capitalized.
	 */
	public static String capFirstChar(String str) {
		return Character.toUpperCase(str.charAt(0)) + str.substring(1);
	}
}
